﻿using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;

using YourLastOptionsDialog.Core.Attributes;
using YourLastOptionsDialog.ViewModels.Options;

namespace YourLastOptionsDialog
{
    /// <summary>
    /// Describes an extender to the existing <see cref="OptionsFactory"/>.
    /// </summary>
    public interface IOptionsFactoryExtender
    {
        /// <summary>
        /// Determines the types that should be used for a given property.
        /// The extender should set types only if it is capable of handling the type of property.
        /// If the property should be handled by the existing <see cref="OptionsFactory"/>, the extender
        /// is supposed to simply leave the passed in type references as-is.
        /// </summary>
        /// <param name="property">The property the types need to be determined for.</param>
        /// <param name="optionType">Type of the option to use for the given property.</param>
        /// <param name="optionAttributeType">Type of the option attribute to use for the given property.</param>
        [SuppressMessage("Microsoft.Design", 
            "CA1045:DoNotPassTypesByReference", 
            Justification = "This is by design.")]
        void DetermineTypesFor(PropertyInfo property, ref Type optionType, ref Type optionAttributeType);

        /// <summary>
        /// Sets the custom values of an option.
        /// </summary>
        /// <param name="property">The property the option was created for.</param>
        /// <param name="option">The option that needs its custom values to be set.</param>
        /// <param name="optionAttribute">The option attribute that was applied to the property, if available.</param>
        /// <param name="instance">The instance the property value can be found on.</param>
        void SetCustomValues(PropertyInfo property, Option option, OptionAttribute optionAttribute, object instance);
    }
}